package com.xliee.modules.vehicle.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xliee.modules.sys.entity.UserEntity;
import com.xliee.modules.vehicle.entity.VehicleEntity;
import com.xliee.modules.vehicle.mapper.VehicleMapper;
import com.xliee.modules.vehicle.service.IVehicleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 车辆(设备)信息表 服务实现类
 * </p>
 *
 * @author lisongsong@xliee.com
 * @since 2024-09-13 12:50:06
 */
@Service
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, VehicleEntity> implements IVehicleService {

    @Override
    public VehicleEntity selectByUser(UserEntity user) {
        VehicleEntity vehicle = baseMapper.selectOne(
                new QueryWrapper<VehicleEntity>()
                        .like("owner", user.getUserName())
                        .or().like("phone",user.getUserName())
                        .or().like("drc_id",user.getUserName())
                        .or().like("whole_vehicle_number",user.getUserName())
                        .last("limit 1"));
        return vehicle;
    }
}
